﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace DotNetStar.TheKing.Web.ViewComponents
{
    using Services;
    using Domain;
    public class UserPanelViewComponent:ViewComponent
    {
        private readonly ContentService _contentService;
        private readonly UserService _userService;
        public UserPanelViewComponent(ContentService contentService,UserService userService)
        {
            this._contentService = contentService;
            this._userService = userService;
        }
        public async Task<IViewComponentResult> InvokeAsync(long userId)
        {
            var contentCount = _contentService.GetContentQueable(new ContentQuery { AuthorUserId = userId }).Count();
            var user = await _userService.GetByIdAsync(userId);

            ViewData["ContentCount"] = contentCount;
            ViewData["User"] = user;
            return View();
        }
    }
}
